package com.aspose.cells;

public class GradientFill extends Fill {
   zacl a;
   Object b;
   private zaco f;
   boolean c;
   private GradientStopCollection g;
   int d;
   private Object h;
   Workbook e;

   GradientFill(Object parent, Workbook workbook) {
      this.h = parent;
      this.e = workbook;
      this.g = new GradientStopCollection(this);
      this.d = 24;
      this.c = true;
   }

   void a(GradientFill var1) {
      this.d = var1.d;
      this.c = var1.c;
      if (var1.b != null) {
         if (var1.b instanceof zacn) {
            this.b = new zacn();
            ((zacn)this.b).a((zacn)var1.b);
         } else {
            this.b = new zaco();
            ((zaco)this.b).a((zaco)var1.b);
         }
      } else {
         this.b = null;
      }

      if (var1.a != null) {
         this.a = new zacl();
         this.a.b = var1.a.b;
         this.a.d = var1.a.d;
         this.a.a = var1.a.a;
         this.a.c = var1.a.c;
      } else {
         this.a = null;
      }

      if (var1.f != null) {
         this.f = new zaco();
         this.f.a(var1.f);
      } else {
         this.f = null;
      }

      if (var1.g != null) {
         this.g = new GradientStopCollection(this);
         this.g.a(var1.g);
      } else {
         this.g = null;
      }

   }

   boolean b(GradientFill var1) {
      if (this.d != var1.d) {
         return false;
      } else if (this.c != var1.c) {
         return false;
      } else {
         if (this.b != null || var1.b != null) {
            if (this.b == null || var1.b == null) {
               return false;
            }

            if (var1.b instanceof zacn) {
               if (!((zacn)this.b).b((zacn)var1.b)) {
                  return false;
               }
            } else if (!((zaco)this.b).b((zaco)var1.b)) {
               return false;
            }
         }

         if (this.a != null || var1.a != null) {
            if (this.a == null || var1.a == null) {
               return false;
            }

            if (this.a.b != var1.a.b) {
               return false;
            }

            if (this.a.d != var1.a.d) {
               return false;
            }

            if (this.a.a != var1.a.a) {
               return false;
            }

            if (this.a.c != var1.a.c) {
               return false;
            }
         }

         if (this.f != null || var1.f != null) {
            if (this.f == null || var1.f == null) {
               return false;
            }

            if (!this.f.b(var1.f)) {
               return false;
            }
         }

         if (this.g != null || var1.g != null) {
            if (this.g == null || var1.g == null) {
               return false;
            }

            if (!this.g.b(var1.g)) {
               return false;
            }
         }

         return true;
      }
   }

   public GradientStopCollection getGradientStops() {
      return this.g;
   }

   boolean a() {
      return this.b == null ? true : this.b instanceof zacn;
   }

   zacn b() {
      return this.b != null && this.b instanceof zacn ? (zacn)this.b : null;
   }

   zaco c() {
      return this.b != null && this.b instanceof zaco ? (zaco)this.b : null;
   }

   zaco d() {
      if (this.f == null) {
         this.f = new zaco();
      }

      return this.f;
   }

   zaco e() {
      return this.f;
   }

   public void setGradient(int type, double angle, int direction) {
      this.a = null;
      switch(type) {
      case 0:
         zacn var5 = new zacn();
         var5.a = (int)(angle * (double)zml.j);
         this.b = var5;
         break;
      case 1:
      case 2:
         zaco var7 = new zaco();
         this.b = var7;
         if (type == 2) {
            var7.a = 1;
         } else {
            var7.a = 0;
         }

         switch(direction) {
         case 0:
            var7.b = var7.c = 50000;
            this.f = new zaco();
            this.f.e = this.f.d = -100000;
            return;
         case 1:
            var7.c = var7.e = 50000;
            this.f = new zaco();
            this.f.b = this.f.d = -100000;
            return;
         case 2:
            var7.b = var7.d = 50000;
            this.f = new zaco();
            this.f.c = this.f.e = -100000;
            return;
         case 3:
            var7.e = var7.d = 50000;
            this.f = new zaco();
            this.f.b = this.f.c = -100000;
            return;
         case 4:
            var7.b = var7.e = var7.d = var7.c = 50000;
            return;
         default:
            return;
         }
      case 3:
         zaco var6 = new zaco();
         this.b = var6;
         var6.a = 2;
         var6.b = var6.e = var6.c = var6.d = 50000;
      }

   }

   public int getFillType() {
      if (this.b == null) {
         return 0;
      } else {
         if (this.b instanceof zaco) {
            zaco var1 = (zaco)this.b;
            switch(var1.a) {
            case 0:
               return 1;
            case 1:
               return 2;
            case 2:
               return 3;
            }
         }

         return 0;
      }
   }

   public int getDirectionType() {
      if (this.b == null) {
         return 5;
      } else {
         if (this.b instanceof zaco) {
            int var1 = 100000;
            zaco var2 = (zaco)this.b;
            switch(var2.a) {
            case 0:
            case 1:
               if (var2.c == var1 && var2.b == var1) {
                  return 3;
               }

               if (var2.c == var1 && var2.e == var1) {
                  return 2;
               }

               if (var2.b == var1 / 2 && var2.e == var1 / 2 && var2.c == var1 / 2 && var2.d == var1 / 2) {
                  return 4;
               }

               if (var2.d == var1 && var2.b == var1) {
                  return 1;
               }

               if (var2.d == var1 && var2.e == var1) {
                  return 0;
               }
               break;
            case 2:
               return 5;
            }
         }

         return 5;
      }
   }

   public float getAngle() {
      return this.b != null && this.b instanceof zacn ? (float)((zacn)this.b).a / (float)zml.j : 0.0F;
   }

   public void setAngle(float value) {
      if (this.b != null && this.b instanceof zacn) {
         ((zacn)this.b).a = (int)(value * (float)zml.j);
      }

   }

   void a(Style var1, Workbook var2) {
      this.a(var2);
      zakp var3;
      zakp var4;
      if (this.a.a != 3) {
         switch(this.a.c) {
         case 1:
         case 3:
            var3 = this.g.get(0).a;
            var4 = this.g.get(1).a;
            break;
         case 2:
         case 4:
            var3 = this.g.get(1).a;
            var4 = this.g.get(0).a;
            break;
         default:
            var3 = new zakp(false);
            var4 = new zakp(false);
         }
      } else {
         var3 = this.g.get(0).a;
         var4 = this.g.get(1).a;
      }

      var1.a(var3, var4, this.a.a, this.a.c);
   }

   public Color getGradientColor1() {
      if (this.g != null && this.g.getCount() != 0) {
         this.a(this.e);
         if (this.a.a != 3) {
            switch(this.a.c) {
            case 1:
            case 3:
               return this.g.get(0).a.b(this.e);
            case 2:
            case 4:
               return this.g.get(1).a.b(this.e);
            default:
               return Color.getEmpty();
            }
         } else {
            return this.g.get(0).a.b(this.e);
         }
      } else {
         return Color.getEmpty();
      }
   }

   public Color getGradientColor2() {
      if (this.g != null && this.g.getCount() != 0) {
         this.a(this.e);
         if (this.a.a != 3) {
            switch(this.a.c) {
            case 1:
            case 3:
               return this.g.get(1).a.b(this.e);
            case 2:
            case 4:
               return this.g.get(0).a.b(this.e);
            default:
               return Color.getEmpty();
            }
         } else {
            return this.g.get(1).a.b(this.e);
         }
      } else {
         return Color.getEmpty();
      }
   }

   public double getGradientDegree() {
      return this.a != null ? this.a.d : 0.0D;
   }

   public void setPresetColorGradient(int presetColor, int style, int variant) {
      this.d = presetColor;
      this.a = new zacl();
      this.a.b = 2;
      this.a.a = style;
      this.a.c = variant;
      switch(style) {
      case 0:
      case 1:
      case 4:
      case 5:
         zacn var4 = new zacn();
         this.b = var4;
         switch(style) {
         case 0:
            var4.a = 315 * zml.j;
            break;
         case 1:
            var4.a = 45 * zml.j;
         case 2:
         case 3:
         default:
            break;
         case 4:
            var4.a = 5400000;
            break;
         case 5:
            var4.a = 0;
         }

         var4.b = true;
         switch(variant) {
         case 1:
            this.g = zvj.a(this, presetColor, false, false);
            return;
         case 2:
            this.g = zvj.a(this, presetColor, true, false);
            return;
         case 3:
            this.g = zvj.a(this, presetColor, false, true);
            return;
         case 4:
            this.g = zvj.a(this, presetColor, true, true);
            return;
         default:
            return;
         }
      case 2:
         this.g = zvj.a(this, presetColor, variant == 1, false);
         zaco var6 = new zaco();
         var6.a = 1;
         this.b = var6;
         var6.b = var6.e = var6.c = var6.d = 50000;
         break;
      case 3:
         zaco var5 = new zaco();
         var5.a = 1;
         this.b = var5;
         this.g = zvj.a(this, presetColor, false, false);
         switch(variant) {
         case 1:
            var5.e = var5.d = 100000;
            break;
         case 2:
            var5.b = var5.d = 100000;
            break;
         case 3:
            var5.c = var5.e = 100000;
            break;
         case 4:
            var5.b = var5.c = 100000;
         }
      }

   }

   public void setOneColorGradient(Color color, double degree, int style, int variant) {
      this.a(1, color, degree, color, 0.0D, 0.0D, style, variant);
   }

   public void setTwoColorGradient(Color color1, Color color2, int style, int variant) {
      this.a(3, color1, 0.0D, color2, 0.0D, 0.0D, style, variant);
   }

   public void setTwoColorGradient(Color color1, double transparency1, Color color2, double transparency2, int style, int variant) {
      this.a(3, color1, 0.0D, color2, transparency1, transparency2, style, variant);
   }

   void a(int var1, zakp var2, double var3, zakp var5, int var6, int var7) {
      this.a = new zacl();
      this.a.a = var6;
      this.a.c = var7;
      this.a.d = var3;
      this.a.b = var1;
      GradientStop var8 = null;
      switch(var6) {
      case 0:
      case 1:
      case 4:
      case 5:
         zacn var9 = new zacn();
         this.b = var9;
         switch(var6) {
         case 0:
            var9.a = 315 * zml.j;
            break;
         case 1:
            var9.a = 45 * zml.j;
         case 2:
         case 3:
         default:
            break;
         case 4:
            var9.a = 5400000;
            break;
         case 5:
            var9.a = 0;
         }

         var9.b = true;
         switch(var7) {
         case 1:
            var8 = new GradientStop(this.g);
            var8.a = var2;
            var8.setPosition(0.0D);
            this.g.a(var8);
            var8 = new GradientStop(this.g);
            var8.a = var5;
            var8.setPosition(100.0D);
            this.g.a(var8);
            return;
         case 2:
            var8 = new GradientStop(this.g);
            var8.a = var5;
            var8.setPosition(0.0D);
            this.g.a(var8);
            var8 = new GradientStop(this.g);
            var8.a = var2;
            var8.setPosition(100.0D);
            this.g.a(var8);
            return;
         case 3:
            var8 = new GradientStop(this.g);
            var8.a = var2;
            var8.setPosition(0.0D);
            this.g.a(var8);
            var8 = new GradientStop(this.g);
            var8.a = var5;
            var8.setPosition(50.0D);
            this.g.a(var8);
            var8 = new GradientStop(this.g);
            var8.a = var2;
            var8.setPosition(100.0D);
            this.g.a(var8);
            return;
         case 4:
            var8 = new GradientStop(this.g);
            var8.a = var5;
            var8.setPosition(0.0D);
            this.g.a(var8);
            var8 = new GradientStop(this.g);
            var8.a = var2;
            var8.setPosition(50.0D);
            this.g.a(var8);
            var8 = new GradientStop(this.g);
            var8.a = var5;
            var8.setPosition(100.0D);
            this.g.a(var8);
            return;
         default:
            return;
         }
      case 2:
         if (var7 != 1) {
            zakp var11 = var2;
            var2 = var5;
            var5 = var11;
         }

         var8 = new GradientStop(this.g);
         var8.a = var2;
         var8.setPosition(0.0D);
         this.g.a(var8);
         var8 = new GradientStop(this.g);
         var8.a = var5;
         var8.setPosition(100.0D);
         this.g.a(var8);
         zaco var12 = new zaco();
         var12.a = 1;
         this.b = var12;
         var12.b = var12.e = var12.c = var12.d = 50000;
         break;
      case 3:
         var8 = new GradientStop(this.g);
         var8.a = var2;
         var8.setPosition(0.0D);
         this.g.a(var8);
         var8 = new GradientStop(this.g);
         var8.a = var5;
         var8.setPosition(100.0D);
         this.g.a(var8);
         zaco var10 = new zaco();
         var10.a = 1;
         this.b = var10;
         switch(var7) {
         case 1:
         default:
            break;
         case 2:
            var10.b = var10.e = 100000;
            break;
         case 3:
            var10.c = var10.d = 100000;
            break;
         case 4:
            var10.e = var10.d = 100000;
            var10.b = var10.c = 100000;
         }
      }

   }

   private void a(int var1, Color var2, double var3, Color var5, double var6, double var8, int var10, int var11) {
      this.a = new zacl();
      this.a.a = var10;
      this.a.c = var11;
      this.a.d = var3;
      this.a.b = var1;
      zakp var12 = new zakp(true);
      zakp var13 = new zakp(true);
      var12.a(2, var2.toArgb());
      if (var1 == 1) {
         var13.a(2, a(var2, var3).toArgb());
      } else {
         var13.a(2, var5.toArgb());
      }

      GradientStop var14 = null;
      label47:
      switch(var10) {
      case 0:
      case 1:
      case 4:
      case 5:
         zacn var15 = new zacn();
         this.b = var15;
         switch(var10) {
         case 0:
            var15.a = 315 * zml.j;
            break;
         case 1:
            var15.a = 45 * zml.j;
         case 2:
         case 3:
         default:
            break;
         case 4:
            var15.a = 5400000;
            break;
         case 5:
            var15.a = 0;
         }

         var15.b = true;
         switch(var11) {
         case 1:
            var14 = new GradientStop(this.g);
            var14.a = var12;
            var14.setPosition(0.0D);
            this.g.a(var14);
            var14 = new GradientStop(this.g);
            var14.a = var13;
            var14.setPosition(100.0D);
            this.g.a(var14);
            break label47;
         case 2:
            var14 = new GradientStop(this.g);
            var14.a = var13;
            var14.setPosition(0.0D);
            this.g.a(var14);
            var14 = new GradientStop(this.g);
            var14.a = var12;
            var14.setPosition(100.0D);
            this.g.a(var14);
            break label47;
         case 3:
            var14 = new GradientStop(this.g);
            var14.a = var12;
            var14.setPosition(0.0D);
            this.g.a(var14);
            var14 = new GradientStop(this.g);
            var14.a = var13;
            var14.setPosition(50.0D);
            this.g.a(var14);
            var14 = new GradientStop(this.g);
            var14.a = var12;
            var14.setPosition(100.0D);
            this.g.a(var14);
            break label47;
         case 4:
            var14 = new GradientStop(this.g);
            var14.a = var13;
            var14.setPosition(0.0D);
            this.g.a(var14);
            var14 = new GradientStop(this.g);
            var14.a = var12;
            var14.setPosition(50.0D);
            this.g.a(var14);
            var14 = new GradientStop(this.g);
            var14.a = var13;
            var14.setPosition(100.0D);
            this.g.a(var14);
         default:
            break label47;
         }
      case 2:
         if (var11 != 1) {
            zakp var17 = var12;
            var12 = var13;
            var13 = var17;
         }

         var14 = new GradientStop(this.g);
         var14.a = var12;
         var14.setPosition(0.0D);
         this.g.a(var14);
         var14 = new GradientStop(this.g);
         var14.a = var13;
         var14.setPosition(100.0D);
         this.g.a(var14);
         zaco var18 = new zaco();
         var18.a = 1;
         this.b = var18;
         var18.b = var18.e = var18.c = var18.d = 50000;
         break;
      case 3:
         var14 = new GradientStop(this.g);
         var14.a = var12;
         var14.setPosition(0.0D);
         this.g.a(var14);
         var14 = new GradientStop(this.g);
         var14.a = var13;
         var14.setPosition(100.0D);
         this.g.a(var14);
         zaco var16 = new zaco();
         var16.a = 1;
         this.b = var16;
         switch(var11) {
         case 1:
            var16.e = var16.d = 100000;
            break;
         case 2:
            var16.b = var16.d = 100000;
            break;
         case 3:
            var16.c = var16.e = 100000;
            break;
         case 4:
            var16.b = var16.c = 100000;
         }
      }

      if (this.g.getCount() > 0) {
         this.g.get(0).setTransparency(var6);
         if (this.g.getCount() > 1) {
            this.g.get(1).setTransparency(var8);
         }
      }

   }

   public int getGradientColorType() {
      this.a(this.e);
      return this.a.b;
   }

   public int getPresetColor() {
      return this.d;
   }

   public void setPresetColor(int value) {
      this.d = value;
      if (this.a != null) {
         this.a.b = 2;
      }

      this.g = zvj.a(this, value, false, false);
   }

   public int getVariant() {
      this.a(this.e);
      return this.a.c;
   }

   public int getGradientStyle() {
      this.a(this.e);
      return this.a.a;
   }

   private void a(Workbook var1) {
      if (this.a == null) {
         this.a = new zacl();
         if (this.b != null) {
            if (this.b instanceof zacn) {
               zacn var2 = (zacn)this.b;
               switch(var2.a) {
               case 0:
                  this.a.a = 5;
                  break;
               case 2700000:
                  this.a.a = 1;
                  break;
               case 5400000:
                  this.a.a = 4;
                  break;
               case 18900000:
                  this.a.a = 0;
                  break;
               default:
                  this.a.a = 4;
               }

               if (this.g != null) {
                  switch(this.g.getCount()) {
                  case 0:
                  case 1:
                     break;
                  case 2:
                     this.a.c = 1;
                     this.a.b = 3;
                     break;
                  case 3:
                     if (this.g.get(0).getPosition() == 0.0D && this.g.get(1).getPosition() == 50.0D && this.g.get(2).getPosition() == 100.0D && this.g.get(0).a.c(var1) == this.g.get(2).a.c(var1)) {
                        this.a.b = 3;
                        this.a.c = 3;
                     } else if (this.g.get(0).getPosition() == 50.0D && this.g.get(1).getPosition() == 0.0D && this.g.get(2).getPosition() == 100.0D && this.g.get(1).a.c(var1) == this.g.get(2).a.c(var1)) {
                        this.a.b = 3;
                        this.a.c = 4;
                     } else {
                        this.a.b = 2;
                        this.d = 24;
                     }
                     break;
                  default:
                     this.a.b = 2;
                     this.d = 24;
                  }
               } else {
                  this.a.b = 2;
                  this.d = 24;
               }
            } else if (this.b instanceof zaco) {
               boolean var4 = this.g != null && this.g.getCount() == 2;
               zaco var3 = (zaco)this.b;
               if (var3.d == 50000 && var3.b == 50000 && var3.c == 50000 && var3.d == 50000) {
                  this.a.a = 2;
                  this.a.c = 1;
                  this.a.b = var4 ? 3 : 2;
               } else {
                  this.a.a = 3;
                  this.a.b = var4 ? 3 : 2;
                  if (var3.b == 0) {
                     if (var3.c == 0) {
                        this.a.c = 1;
                     } else {
                        this.a.c = 3;
                     }
                  } else if (var3.b == 100000) {
                     if (var3.c == 0) {
                        this.a.c = 2;
                     } else {
                        this.a.c = 4;
                     }
                  }
               }
            }

         }
      }
   }

   static Color a(Color var0, double var1) {
      int var3 = com.aspose.cells.a.c.zh.b(var0) & 255;
      int var4 = com.aspose.cells.a.c.zh.c(var0) & 255;
      int var5 = com.aspose.cells.a.c.zh.d(var0) & 255;
      double var6;
      if (var1 < 0.5D) {
         var6 = var1 * 2.0D;
         var0 = Color.fromArgb((int)((double)var3 * var6), (int)((double)var4 * var6), (int)((double)var5 * var6));
      } else if (var1 > 0.5D) {
         var6 = (var1 - 0.5D) * 2.0D;
         var0 = Color.fromArgb((int)((double)var3 + (double)(255 - var3) * var6), (int)((double)var4 + (double)(255 - var4) * var6), (int)((double)var5 + (double)(255 - var5) * var6));
      }

      return var0;
   }
}
